import Vue from "vue";
import VueRouter from "vue-router";

import Layout from "@/layout";

Vue.use(VueRouter);

/**
 *
 * 此为目前路由的注释
 *
 * 目前路由格式为大的内容套着小的
 * 其中
 * path： 路径
 * component： 页面在项目中的位置
 * hidden：是否显示在菜单中
 * meta：{
 *  title：在侧边菜单栏中显示的名字
 *  icon： 图标的class or 名字（使用element的icon 和 使用 目前我所编写的 svg-icon 并不冲突 如果导入el的图标则直接写 例：el-icon-house， 导入我内置的图标 就直接写我在图标的 icon-class 例： 404）
 *  activeMenu：设置侧边菜单默认高亮路径，如不设置就按照path进行获取
 * }
 *
 * 以上为目前第一版的路由介绍，之后如果有进行修改会再补充
 *
 */

const constantRoutes = [
  {
    path: "/login",
    name: "login",
    component: () => import("../views/LoginView.vue"),
    hidden: true,
  },
  //   404页面设置
  {
    path: "/404",
    component: () => import("@/views/error-page/404.vue"),
    hidden: true,
  },
  {
    path: "/",
    name: "index",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        name: "dashboard",
        component: () => import("@/views/dashboard/IndexView"),
        meta: { title: "主页", icon: "el-icon-house" },
      }
    ],
  },
  //hyq
  {
    path: "/map",
    name: "map",
    component: Layout,
    children: [
      {
        path: "index",
        name: "mapIndex",
        component: () => import("@/views/story/StoryMap"),
        meta: { title: "地图", icon: "el-icon-map-location" },
      }
    ],
  },
  {
    path: "/story",
    name: "story",
    component: Layout,
    children: [
      {
        path: "index",
        name: "storyIndex",
        component: () => import("@/views/story/StoryView"),
        meta: { title: "故事管理", icon: "el-icon-reading" },
      }
    ],
  },
  {
    path: "/drama",
    name: "drama",
    component: Layout,
	hidden: true,
    children: [
      {
        path: "index/:storyId",
        name: "dramaIndex",
        component: () => import("@/views/story/DramaView"),
		meta: { title: "剧情管理"},
      }
    ],
  },
  {
    path: "/scenic",
    name: "scenic",
    component: Layout,
    children: [
      {
        path: "index",
        name: "scenicIndex",
        component: () => import("@/views/scenic/scenicIndex"),
        meta: { title: "景区管理", icon: "el-icon-guide" },
      }
    ],
  },
  {
      path: "/order",
      name: "order",
      component: Layout,
      children: [
        {
          path: "index",
          name: "orderIndex",
          component: () => import("@/views/order/IndexView"),
          meta: { title: "订单管理", icon: "el-icon-goods" },
        },
      ],
    },
	{
	    path: "/product",
	    name: "product",
	    component: Layout,
	    children: [
		  {
			path: "index",
			name: "productIndex",
			component: () => import("@/views/product/ProductView"),
			meta: { title: "周边管理", icon: "el-icon-s-goods" },
		  },
	    ],
	  },
	  {
		  path: "/inventory",
		  name: "inventory",
		  component: Layout,
		  children: [
		  {
			path: "index",
			name: "inventoryIndex",
			component: () => import("@/views/inventory/InventoryView"),
			meta: { title: "库存管理", icon: "el-icon-box" },
		  },
		  ],
		},
  
  
  // {
  //   path: "/*",
  //   redirect: "/404",
  //   hidden: true,
  // },
];

const router = new VueRouter({
  // mode: "history",
  base: process.env.BASE_URL,
  routes: constantRoutes,
});

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push;
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

export default router;
